<template>
	<view class="x">
		<!-- 左边的数据 -->
		<view class="y">
			<view v-for="(item,index) in shu" :key="index" class="zuo">
				<view :class="{'yanse' : banduan===index}" @click="dian(item.id,index)">{{item.name}}</view>
			</view>
		</view>


		<!-- 右边的数据 -->
		<view class="y din">
			
			<image :src="din.picUrl" style="width: 600rpx; height: 200rpx;margin: 0 auto;"></image>
			<view style="margin: 0 auto; margin-top: 15rpx;">{{din.desc}}</view>
		
		<view class="x da" >
		<view  v-for="(item,index) in nei" :key="index">
			<image :src="item.picUrl" class="tupian"></image>
			<view class="wenzi">{{item.name}}</view>
		</view>
		</view>
		
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				banduan:0,
				shu: [],//左边的导航栏
				din: [],//顶部的图片和文字
				nei:[]//图片下面的数据
			}
		},
		onLoad() {
			uni.request({
				url: 'http://47.91.230.137:8086/wx/catalog/index', //网站接口
				success: (res) => {
					// debugger//断点
					this.shu = res.data.data.categoryList//左边的数据
					this.din = res.data.data.currentCategory//顶部的图片和文字
					this.nei = res.data.data.currentSubCategory//图片下面的数据
				}
			})
		},
		methods:{
			dian(id,index){
				this.banduan=index
				uni.request({
					url:'http://47.91.230.137:8086/wx/catalog/current?id='+id,
					success:(res) => {
						// debugger
						this.din = res.data.data.currentCategory//顶部的图片和文字
						this.nei = res.data.data.currentSubCategory//图片下面的数据
					}
				})
			}
		}

	}
</script>

<style>
	.x {
		display: flex;
		/* 打开弹性布局 */
		flex-direction: row;
		/* 横 */

	}

	.y {
		display: flex;
		/* 打开弹性布局 */
		flex-direction: column;
		/* 竖 */
	}

	.din {
		margin: 0 auto;
	}
	.da{
		display: flex;
		flex-wrap: wrap;
		justify-content:flex-start;
	}
	.wenzi{
		display: flex;
		justify-content: center;
		padding-left: 35rpx;
		font-size: 35rpx;
	}
.tupian{
	width: 150rpx;
	height: 150rpx;
	padding-left: 45rpx;
}
	.zuo {
		width: 45px;
		padding: 16px;
		/* 内边距 */
		color: #5a5a5a;
		margin-left: 3px;
		/* 外左边距 */
		background-color: #f8f8f8;
		font-size: 38rpx;
		border-bottom: solid;
		border-width: 1rpx;
		border-color: #bdbdbd;
		margin: 0 auto;
	}
	
	/* 点击变色 */
	.yanse{
		color: #ffaa7f;
		font-weight: 900;
		border-left:5rpx  solid #ffaa00;
	}
</style>